#ifndef _MVO_H
#define _MVO_H

#include "XNCtrl.h"
#include "SceneProcessor.h"
#include "VSCamera.h"
#include "HandManipulation.h"
#include "VSObject.h"
#include "ToolBox.h"

class MVO
{
public:
	MVO(void);
	~MVO(void);

public:
	void MainLoop();
	void XNNewUser(xn::UserGenerator& generator, XnUserID user, void* pCookie);
	void XNLostUser(xn::UserGenerator& generator, XnUserID user, void* pCookie);
	void Init(int * pargc, char ** argv);
	void keyboard (unsigned char key, int x, int y);
	void specialkeyboard (int key, int x, int y);
	void reshape(int w, int h);
	void idle();
	void display();

private:
	void glInit(int * pargc, char ** argv);
	void modeInit(int * pargc, char ** argv);
	void getAllData();
	void getAllCtrl();
	void renderVRdisplay();
	void renderARdisplay();
	void renderCamera();
	void renderVRVS();
	void renderARVS();
	void renderTexture();
	void renderOther();
	void renderFrame();
	void renderHand();
	void renderToolBox();
	void renderStatus();
	void getVRGround(int objIdx);
	void getARGround(int objIdx);
	void manipulateCamera();
	//void renderToolOperation();

private:
	xn::SceneMetaData m_sceneMD;
	xn::DepthMetaData m_depthMD;
	xn::ImageMetaData m_imageMD;
	int m_texWidth;
	int m_texHeight;
	XnUInt32 m_XRes;
	XnUInt32 m_YRes;
	int m_nPlayer;
	int m_winw;
	int m_winh;

	XNCtrl* xnCtrl;
	SceneProcessor* scenePro;
	VSCamera m_camera;
	HandManipulation * handManp;
	ToolBox* m_toolbox;
	TrackData * m_pCameraLastCtrl, * m_pObjectLastCtrl, * m_pMenuLastCtrl;
	TrackData * m_pCameraCurCtrl, * m_pObjectCurCtrl, * m_pMenuCurCtrl;
	int m_nCamCtrl,m_nObjCtrl,m_nMenuCtrl;

	int m_frame;
	int m_time,m_timebase;
	char* m_frame_count;
	double fpsx,fpsy,statusx,statusy;
	std::vector<VSObject> m_objectList;
	std::vector<VSObject> m_virtualScene;

	cv::Mat ScreenMat;
	int count;

	int m_sceneL,m_sceneW,m_sceneH;
	float * m_ground;
	std::string m_statusMsg;
	bool m_bSelectObject,m_bSelectMenu;

	int m_appMode;
	bool m_bCalibration;
	Point3D m_zeroPoint;
	bool m_bRenderTexture;
	float* m_refGround;
};

#endif